package com.szy.controller;

import com.szy.pojo.User;
import com.szy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public String login(User user,HttpSession session){
        User login = userService.login(user);
        session.setAttribute("user", login);
        if(login == null){
            return "login";
        }
        else{
            return "redirect:/article/index/1";
        }
    }
}
